function fm_version(){
	return "1.03";
}

(function(f){var d=document,s=d.createElement('script');s.setAttribute('type','application/javascript');s.textContent = '('+f.toString()+')()';(d.body||d.head||d.documentElement).appendChild(s);s.parentNode.removeChild(s)})(function(){

/*
If you want me to add another language, you can send an e-mail to zyphir.randrott@gmail.com.
Make your translation using the structure below and I will update the script as soon as possible ;)
*/

var fm_lang = {
	AFORTSNEARBY: 'Allied barracks nearby',
	AFORTSATTACKED: 'Allied barracks attacked',
	SEARCHMORE: 'Search for barracks',
	PLEASEWAIT: 'Please wait...',
	NORESULTS: 'No results',
	UPDATING: '<b>New data!</b> Updating...',
	SORTBYPROXIMITY: 'Sort by <b>proximity</b>',
	SORTBYTYPE: 'Sort by <b>type</b>',
	CLOSE: '<b>Close</b>',
	GOTOFORT: '<b>Go to fort</b>',
	FORTBATTLE: '<b>Fort battle</b>'

};
var fm_langs = {};
fm_langs.fr = {
	AFORTSNEARBY: 'Casernes alliées proches',
	AFORTSATTACKED: 'Casernes alliées attaquées',
	SEARCHMORE: 'Chercher les casernes',
	PLEASEWAIT: 'Veuillez patienter...',
	NORESULTS: 'Aucun résultat',
	UPDATING: '<b>Nouvelles données!</b> Mise a jour...',
	SORTBYPROXIMITY: 'Trier par <b>proximité</b>',
	SORTBYTYPE: 'Trier par <b>type</b>',
	CLOSE: '<b>Fermer</b>',
	GOTOFORT: '<b>Va au fort</b>',
	FORTBATTLE: '<b>Bataille de fort</b>'

};
var fm_langs = {};
fm_langs.pl = {
	AFORTSNEARBY: 'Forty sojusznicze w pobliżu',
	AFORTSATTACKED: 'Atkakowane sojusznicze forty',
	SEARCHMORE: 'Wyszukiwanie koszar',
	PLEASEWAIT: 'Proszę czekać...',
	NORESULTS: 'Brak rezultatów',
	UPDATING: '<b>Nowe dane!</b> Zaktualizowano...',
	SORTBYPROXIMITY: 'Sortuj wg <b>odległości</b>',
	SORTBYTYPE: 'Sortuj wg <b>typów</b>',
	CLOSE: '<b>Zamknij</b>',
	GOTOFORT: '<b>Idź do fortu</b>',
	FORTBATTLE: '<b>Bitwa o fort</b>'

};
var fm_langname = location.host.match(/(\D+)\d+\./);
if(fm_langname && fm_langs[fm_langname[1]]) fm_lang = fm_langs[fm_langname[1]];

  function fm_addGlobalStyle(css){
	var head, style;
	head = document.getElementsByTagName('head')[0];
	if (!head) {return;}
	style = document.createElement('style');
	style.type = 'text/css';
	style.innerHTML = css;
	head.appendChild(style);
  }

  function fm_getCookie(c_name){
	if (document.cookie.length>0){
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1){
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
	  return unescape(document.cookie.substring(c_start,c_end));
	  }
	}
	return "";
  }
  
  function fm_setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
  }

  function fm_sortby(index,direction) {
	return function(a,b){
		a = a[index];
		b = b[index];
		return a == b ? 0 : (a < b ? -1*direction : direction)
		}
  }

  function fm_calcprox(x, y){
	var from=WMap.coordWeirdToCoordNormal(pos.x,pos.y);
	var to=WMap.coordWeirdToCoordNormal(x,y);
	fm_disttime = Math.round(Math.sqrt((from.x-to.x)*(from.x-to.x)+(from.y-to.y)*(from.y-to.y))*Character.speed);
	return fm_disttime;
  }
   
  function fm_calctime(fm_disttime){
	var hours = Math.floor(fm_disttime/60);
	var minutes = fm_disttime%60;
	if (String(minutes).length == 1) {minutes="0"+minutes};
	fm_transittime = hours + ":" + minutes;
	return fm_transittime;
  }

  function fm_lvl_fort_src(lvl, fm_fort_type){
	switch (parseInt(lvl)) {
	 case 0:
		switch (parseInt(fm_fort_type)) {
		 case 1:
		  lvl_fort_src ="";
		  break;
		 case 2:
		  lvl_fort_src ="";
		  break;
		 case 3:
		  lvl_fort_src ="";
		  break;
		}
		break;
	 case 1:
		switch (parseInt(fm_fort_type)) {
		 case 1:
		  lvl_fort_src ="";
		  break;
		 case 2:
		  lvl_fort_src ="";
		  break;
		 case 3:
		  lvl_fort_src ="";
		  break;
		}
		break;
	 case 2:
		switch (parseInt(fm_fort_type)) {
		 case 1:
		  lvl_fort_src ="";
		  break;
		 case 2:
		  lvl_fort_src ="";
		  break;
		 case 3:
		  lvl_fort_src ="";
		  break;
		}
		break;
	}
	return lvl_fort_src;
  }

  function fm_add_popup(obj, strpopup){
	obj.addMousePopup(new MousePopup(unescape(strpopup).replace(/(\d+)/g,"<b>$1</b>")));
  }

  function fm_init(){
	fm_save_list_forts = "0";
	if($('scroll_to_fort_list').innerHTML.length == 98 || $('scroll_to_fort_list').innerHTML.length == 100){ // FF:98 - Chrome:100
	  fm_verticalpos = parseInt($('chatwindow').getSize().size.y+40);
	  fm_searchmore="only";
	  fm_searchonly=true;
	}
	else{
	  if($('scroll_to_fort_list').innerHTML == ""){
		fm_verticalpos = parseInt($('chatwindow').getSize().size.y);
	  }
	  else {
		fm_verticalpos = 103;
	  }
	fm_searchmore=false;
	fm_searchonly=false;
	}
	fm_addGlobalStyle('#scroll_to_fort_list {bottom:'+fm_verticalpos+'px;}');
	fm_addGlobalStyle('#scroll_to_fort_list {width:auto;}');
	fm_addGlobalStyle('#fort_list_closer {left:0px; margin : 0 auto; position:relative;}');
	fm_addGlobalStyle('#new_fort_table td {vertical-align:top; padding:0px 0px 1px 3px;}');
	fm_addGlobalStyle('#new_fort_table td.tdmiddle {vertical-align:middle;}');
	fm_addGlobalStyle('#new_fort_table td.tdbottom {vertical-align:bottom;}');
  
	fm_tw_listforts = new Array(["1","20"],["89","53"],["41","155"],["94","303"],["1","420"],["59","377"],
						  ["1","724"],["93","652"],["58","648"],["8","934"],["92","847"],["38","900"],
						  ["194","115"],["110","88"],["149","175"],["186","308"],["113","457"],["148","410"],
						  ["117","571"],["190","705"],["148","649"],["104","934"],["194","854"],["153","895"],
						  ["291","30"],["209","168"],["240","102"],["207","434"],["296","427"],["259","367"],
						  ["212","644"],["295","702"],["256","636"],["289","896"],["207","768"],["247","895"],
						  ["315","220"],["395","2"],["354","125"],["389","280"],["311","302"],["354","350"],
						  ["394","721"],["309","515"],["348","635"],["395","902"],["321","770"],["346","893"],
						  ["499","245"],["408","76"],["453","148"],["404","472"],["493","404"],["443","396"],
						  ["404","594"],["490","627"],["444","626"],["416","894"],["499","869"],["452","877"],
						  ["594","97"],["514","74"],["550","107"],["596","376"],["507","483"],["542","408"],
						  ["514","705"],["593","516"],["554","650"],["506","769"],["593","891"],["560","870"],
						  ["696","129"],["604","214"],["646","116"],["610","444"],["698","303"],["655","376"],
						  ["612","673"],["691","574"],["651","597"],["603","992"],["690","801"],["643","868"],
						  ["739","31"],["707","11"],["754","164"],["795","397"],["705","442"],["751","373"],
						  ["706","557"],["797","587"],["755","664"],["703","891"],["790","982"],["743","823"],
						  ["898","177"],["806","226"],["848","127"],["806","256"],["894","473"],["845","380"],
						  ["802","701"],["894","529"],["854","642"],["805","977"],["896","857"],["840","954"],
						  ["908","105"],["991","52"],["950","73"],["998","489"],["907","268"],["938","321"],
						  ["923","713"],["994","535"],["947","648"],["915","943"],["994","805"],["947","835"]);
  
	new Ajax('game.php?window=fort_overview', {
	  method:'post',
	  data:{},
	  onComplete:function(data) {
		//alert(data);
		fm_search_list_forts = new RegExp("<div id=\\\\\"ownforts\\\\\">\.+<div id=\\\\\"lastbattle\\\\\">");
		fm_search_list_forts = data.match(fm_search_list_forts);
		fm_search_battle_forts = new RegExp("<div id=\\\\\"incomingbattle\\\\\">\.+<div id=\\\\\"ownforts\\\\\">");
		fm_search_battle_forts = data.match(fm_search_battle_forts);
		fm_search_coord_battle_forts = new RegExp("'\\d+_\\d+'", "g");
		fm_search_coord_battle_forts = String(String(fm_search_battle_forts).match(fm_search_coord_battle_forts));
	
		fm_make_array(fm_searchmore, fm_search_list_forts);
	  }
	}).request();
  }

  function fm_make_array(getsearchmore, fm_search_list_forts){
	fm_searchmore = getsearchmore;
	fm_saveposition=pos.x+"_"+pos.y;
	fm_savecharspeed=Character.speed;
	$('footer_fort_overview_icon').parentNode.style.display = "inline";
	$('footer_fort_overview_icon').parentNode.href = "javascript:FM.fm_check('"+fm_searchmore+"')";  
  
	FM.fort = {};
	  for (i=0;i<fm_tw_listforts.length;i++){
		FM.fort["_"+fm_tw_listforts[i][0]+"_"+fm_tw_listforts[i][1]+"_"] = {};
		FM.fort["_"+fm_tw_listforts[i][0]+"_"+fm_tw_listforts[i][1]+"_"].x = fm_tw_listforts[i][0];
		FM.fort["_"+fm_tw_listforts[i][0]+"_"+fm_tw_listforts[i][1]+"_"].y = fm_tw_listforts[i][1];
		FM.fort["_"+fm_tw_listforts[i][0]+"_"+fm_tw_listforts[i][1]+"_"].duration = fm_calcprox(FM.fort["_"+fm_tw_listforts[i][0]+"_"+fm_tw_listforts[i][1]+"_"].x, FM.fort["_"+fm_tw_listforts[i][0]+"_"+fm_tw_listforts[i][1]+"_"].y);
		FM.fort["_"+fm_tw_listforts[i][0]+"_"+fm_tw_listforts[i][1]+"_"].size = i%3;
	  }
  
	if (fm_save_list_forts == "0"){
	  fm_save_list_forts = String(fm_search_list_forts);
	}
	else {
	  fm_addGlobalStyle('#scroll_to_fort_list {bottom:'+parseInt($('chatwindow').getSize().size.y+40)+'px;}');
	  $('scroll_to_fort_list').innerHTML = '<table id="new_fort_table" cellspacing="0"><tr><td><table><tr id="updating" style="display:inline"><td style="font-size: 8pt;" nowrap>'+FM.lang.UPDATING+'</td><td></td><td></td></tr></table></td></tr></table>';
	}
  
	fm_fortname_ind2 = 0;
	fm_fortowner_ind1 = fm_save_list_forts.indexOf("fortOverviewTitle\\\">", fm_fortname_ind2);
	fm_fortowner_ind2 = fm_save_list_forts.indexOf("<\\\/h2>", fm_fortowner_ind1);
	fm_fortowner = unescape((fm_save_list_forts.substring(fm_fortowner_ind1+20, fm_fortowner_ind2)).replace(/\\/g,"%"));
	fm_fortname_ind2=fm_fortowner_ind2+6;
	
	fm_tab_lines=0;
	fm_save_tab_lines=9999;
	fm_fortposx_ind1 = 1;
	fm_i=0;
	fm_fort_type = 1;
	fm_forts_array = new Array();
  
	while (fm_fortposx_ind1 > 0) {
	  if(fm_save_list_forts.indexOf("fortOverviewTitle\\\">", fm_fortname_ind2) < fm_save_list_forts.indexOf("scroll_map_to_pos(", fm_fortname_ind2) && fm_save_list_forts.indexOf("fortOverviewTitle\\\">", fm_fortname_ind2) != -1){
		fm_fortowner_ind1 = fm_save_list_forts.indexOf("fortOverviewTitle\\\">", fm_fortname_ind2);
		fm_fortowner_ind2 = fm_save_list_forts.indexOf("<\\\/h2>", fm_fortowner_ind1);
		fm_fortowner = unescape((fm_save_list_forts.substring(fm_fortowner_ind1+20, fm_fortowner_ind2)).replace(/\\/g,"%"));
		fm_fort_type = 2;
	  }
	  fm_fortposx_ind1 = fm_save_list_forts.indexOf("scroll_map_to_pos(", fm_fortname_ind2);
	  if (fm_fortposx_ind1 == -1) {
		break;}
	  fm_fortposx_ind2 = fm_save_list_forts.indexOf(",", fm_fortposx_ind1);
	  fm_fortposx = parseInt(fm_save_list_forts.substring(fm_fortposx_ind1+18, fm_fortposx_ind2));
	  fm_fortposy_ind2 = fm_save_list_forts.indexOf(")", fm_fortposx_ind2);
	  fm_fortposy = parseInt(fm_save_list_forts.substring(fm_fortposx_ind2+1, fm_fortposy_ind2));
	  fm_fortname_ind1 = fm_save_list_forts.indexOf("')\\\">", fm_fortposy_ind2);
	  fm_fortname_ind2 = fm_save_list_forts.indexOf("<\\\/a>", fm_fortname_ind1);
	  fm_fortname = unescape((fm_save_list_forts.substring(fm_fortname_ind1+5, fm_fortname_ind2)).replace(/\\/g,"%"));
	  fm_fortname_ind2 = fm_fortname_ind2+5;
	  fm_disttime = fm_calcprox(fm_fortposx, fm_fortposy);
	  
	  fm_forts_array[fm_i] = new Array(13);
	  fm_forts_array[fm_i]={l_index:fm_i, l_time:fm_disttime, l_fortname:fm_fortname, l_x:fm_fortposx, l_y:fm_fortposy, l_coord:fm_fortposx+"_"+fm_fortposy, l_owner:fm_fortowner, l_lvl:FM.fort["_"+fm_fortposx+"_"+fm_fortposy+"_"].size, l_type:fm_fort_type, l_id:"-1", l_stars:"-1", l_hotelpopup:"-1", l_battle:"-1"};
  
	  fm_i++;
	}
  
	for(fm_j=0; fm_j<fm_i; fm_j++){
	  fm_get_ajax_data(fm_j);
	}
	
	fm_prepare_div(fm_i);
  }

  function fm_get_ajax_data(fm_i, fm_gx, fm_gy){
	if (fm_gx != undefined && fm_gy != undefined){
	  fm_x= fm_gx;
	  fm_y = fm_gy;
	}
	else{
	  fm_x = fm_forts_array[fm_i].l_x;
	  fm_y = fm_forts_array[fm_i].l_y;
	}
	new Ajax('game.php?window=fort&x=' + fm_x + '&y=' + fm_y, {
	  method:'post',
	  data:{},
	  onComplete:function(data) {
		//alert(data);
		fm_search_fort_id = new RegExp("fort_profile_(\\d+)_reopen");
		fm_search_fort_id = data.match(fm_search_fort_id);
		if (fm_search_fort_id != null){
		  if (fm_gx == undefined && fm_gy == undefined)	{
			fm_forts_array[fm_i]["l_id"] = fm_search_fort_id[1];
		  }
		  fm_search_battle = new RegExp("'fort_battlepage'");
		  fm_search_battle = data.match(fm_search_battle);
		  if (fm_search_battle != null){
			fm_forts_array[fm_i]["l_battle"] = 1;
		  }
		  else {
			fm_forts_array[fm_i]["l_battle"] = -2;
		  }
		  new Ajax('game.php?window=fort_building_barracks&fort_id=' + fm_search_fort_id[1], {
			method:'post',
			data:{},
			onComplete:function(data) {
			  //alert(data);
			  fm_search_fort_name = new RegExp("'\\);\\\\\">(\.+)<\\\\\/a><br");
			  fm_search_fort_name = data.match(fm_search_fort_name);
			  if (fm_search_fort_name != null){
				if (fm_gx != undefined && fm_gy != undefined){
				  fm_search_fort_id = new RegExp("fort_id: (\\d+)},");
				  fm_search_fort_id = data.match(fm_search_fort_id);
				  if (fm_forts_array[fm_i]["l_fortname"] == "fortattack"){
					fm_forts_array[fm_i]["l_index"] = fm_i+1000;
				  }
				  else {
					fm_forts_array[fm_i]["l_index"] = fm_i;
				  }
				  fm_forts_array[fm_i]["l_fortname"]=unescape((fm_search_fort_name[1]).replace(/\\/g,"%"));
				  fm_forts_array[fm_i]["l_id"] = fm_search_fort_id[1];
				}
				fm_search_hotel_stars = new RegExp("star(\\d+).png");
				fm_search_hotel_stars = data.match(fm_search_hotel_stars);
				fm_forts_array[fm_i]["l_stars"] = fm_search_hotel_stars[1];
				fm_search_hotel_popup = new RegExp("room_name\\\\\">.+<\\\\\/span> (.+)<\\\\\/td>\\\\n\\\\n");
				fm_search_hotel_popup = data.match(fm_search_hotel_popup);
				fm_forts_array[fm_i]["l_hotelpopup"] = parseFloat(fm_search_hotel_popup[1]);
			  }
			  else if (fm_gx != undefined && fm_gy != undefined && fm_search_fort_name == null){
				fm_forts_array[fm_i]["l_id"] = -2;
				fm_forts_array[fm_i]["l_stars"] = -2;
				fm_forts_array[fm_i]["l_hotelpopup"] = -2;
			  }
			}
		  }).request();
		}
		else {
		  fm_forts_array[fm_i]["l_id"] = -2;
		  fm_forts_array[fm_i]["l_stars"] = -2;
		  fm_forts_array[fm_i]["l_hotelpopup"] = -2;
		}
	  }
	}).request();
  }

  function fm_prepare_div(fm_i){
	if (fm_forts_array[fm_i-1] != undefined){
	  if (fm_forts_array[fm_i-1]["l_id"] == -1 || fm_forts_array[fm_i-1]["l_stars"] == -1 || fm_forts_array[fm_i-1]["l_hotelpopup"] == -1 || fm_forts_array[fm_i-1]["l_battle"] == -1){
		setTimeout(fm_prepare_div, 500, fm_i);
	  }
	  else {
		if (fm_getCookie('sortforts')){
		  fm_make_div(fm_getCookie('sortforts'));
		}
		else {
		  fm_make_div('l_index');
		}
		if (fm_searchmore == true && fm_save_tab_lines == fm_tab_lines) {
		  $('searchmore').innerHTML = '<td style="font-size: 8pt;" nowrap><b>'+FM.lang.NORESULTS+'</b></td><td></td><td></td>';
		  $('searchmore').style.display="inline";
		  if (fm_save_tab_lines == 0 && fm_tab_lines == 0){
			$('footer_fort_overview_icon').parentNode.href = "javascript:FM.fm_show();"; 
			$('sortby').style.display = "none"; 
		  }
		}
		else if (fm_searchmore == true && fm_save_tab_lines != fm_tab_lines){
		  $('footer_fort_overview_icon').parentNode.href = "javascript:FM.fm_show();"; 
		}
		if (fm_searchonly != true){
		  fm_addGlobalStyle('#scroll_to_fort_list {bottom: '+fm_verticalpos+'px;}');
		}
	  }
	}
	else{
	  if (fm_searchmore == true){
		$('scroll_to_fort_list').innerHTML = '<table id="new_fort_table" cellspacing="0"><tr><td><table><tr><td></td><td></td><td><div style="cursor: pointer;" id="fort_list_closer" onclick="FM.fm_hide();"></div></td></tr><tr id="searchmore" style="display:inline"><td style="font-size: 8pt;" nowrap><b>'+FM.lang.NORESULTS+'</b></td><td></td><td></td></tr></table></td></tr></table>';
		$('footer_fort_overview_icon').parentNode.href = "javascript:FM.fm_show();"; 
	  }
	}
  }

  function fm_make_div(index){
	fm_forts_array.sort(fm_sortby(index, 1));
	index == "l_index" ? index = "l_time" : index = "l_index";

	fm_forts_div = '<table id="new_fort_table" cellspacing="0"><tr><td><table>';
	fm_tab_lines = 0;
	for (fm_j=0; fm_j<fm_forts_array.length; fm_j++){
	  if (fm_forts_array[fm_j].l_index != "9999") {
		if (fm_tab_lines == 0){
		  if (index == "l_time"){
			fm_fortowner_title = fm_forts_array[fm_j].l_owner;
			fm_sortby_popup = FM.lang.SORTBYPROXIMITY;
		  }
		  else {
			fm_fortowner_title = "";
			fm_sortby_popup = FM.lang.SORTBYTYPE;
		  }
		  fm_forts_div = fm_forts_div +'<tr><td class="tdbottom" style="font-size: 8pt;"><strong>'+fm_fortowner_title+'</strong></td><td><div id="sortby" style="cursor: pointer; background:url(../images/main/map_arrows.png) 20px 0px;  width: 20px; height: 20px; margin : 0 auto;" onclick="FM.fm_make_div(\''+index+'\'); FM.fm_setCookie(\'sortforts\',\''+index+'\',365);"></div></td><td><div style="cursor: pointer;" id="fort_list_closer" onclick="FM.fm_hide();"></div></td></tr>';
		}
		else if (fm_tab_lines%20==0){
		  fm_forts_div = fm_forts_div +'</table></td><td><table><tr><td colspan="3">&nbsp;</td></tr>';
		}
		if (fm_forts_array[fm_j].l_owner != fm_fortowner_title && index == "l_time"){
		  fm_forts_div = fm_forts_div +'<tr><td style="font-size: 8pt;"><strong>'+fm_forts_array[fm_j].l_owner+'</strong></td><td></td><td></td></tr>';
		  fm_fortowner_title = fm_forts_array[fm_j].l_owner;
		}
		fm_forts_div = fm_forts_div +'<tr><td class="tdmiddle" align="left" nowrap><a href="javascript: FM.fm_hide(); WMap.scroll_map_to_pos('+fm_forts_array[fm_j].l_x+','+fm_forts_array[fm_j].l_y+');"><img onLoad="FM.fm_add_popup(this, escape(\''+FM.lang.GOTOFORT+'\'));" src="'+FM.fm_lvl_fort_src(fm_forts_array[fm_j].l_lvl, fm_forts_array[fm_j].l_type)+'"></a> <a';
		if (fm_forts_array[fm_j].l_battle == "1") {
		  fm_forts_div = fm_forts_div +' style="color:#A50010;" onmouseover="this.style.color=\'\';" onmouseout="this.style.color=\'#A50010\';"';
		}
		fm_forts_div = fm_forts_div +' href="javascript: FM.fm_hide(); AjaxWindow.show(\'fort\', {x:'+fm_forts_array[fm_j].l_x+',y:'+fm_forts_array[fm_j].l_y+'}, \''+fm_forts_array[fm_j].l_x+'_'+fm_forts_array[fm_j].l_y+'\');">'+fm_forts_array[fm_j].l_fortname+'</a>'
		if (fm_forts_array[fm_j].l_battle == "1") {
		  fm_forts_div = fm_forts_div +'<a href="javascript: FM.fm_hide(); AjaxWindow.show(\'fort_battlepage\',{fort_id:'+fm_forts_array[fm_j].l_id+'},\''+fm_forts_array[fm_j].l_id+'\');"> <img onLoad="FM.fm_add_popup(this, escape(\''+FM.lang.FORTBATTLE+'\'));" src="" width="12" height="12"></a>';
		}
		fm_forts_div = fm_forts_div +'</td><td class="tdmiddle" style="font-size: 8pt;" align="right">&nbsp;'+fm_calctime(fm_forts_array[fm_j].l_time)+'&nbsp;</td><td class="tdmiddle"><a href="javascript: FM.fm_hide(); AjaxWindow.show(\'fort_building_barracks\',{fort_id:'+fm_forts_array[fm_j].l_id+'},\''+fm_forts_array[fm_j].l_id+'\');"><img onLoad="FM.fm_add_popup(this, escape(fm_forts_array['+fm_j+'].l_hotelpopup));" src="images/hotel_stars/star'+fm_forts_array[fm_j].l_stars+'.png" width="16" height="16"></a></td></tr>';
		fm_tab_lines++;
	  }
	  if (fm_j==fm_forts_array.length-1 && fm_tab_lines == 0){
		fm_sortby_popup="";
		fm_forts_div = fm_forts_div +'<tr><td class="tdbottom" style="font-size: 8pt;"><strong></strong></td><td><div id="sortby" style="cursor: pointer; background:url(../images/main/map_arrows.png) 20px 0px;  width: 20px; height: 20px; margin : 0 auto;"></div></td><td><div style="cursor: pointer;" id="fort_list_closer" onclick="FM.fm_hide();"></div></td></tr>';
	  }
	}
	fm_forts_div = fm_forts_div + '<tr id="searchmore" style="display:none"><td style="font-size: 8pt;"><a style="color:#143B50;" onmouseover="this.style.color=\'\';" onmouseout="this.style.color=\'#143B50\';" href="javascript:FM.fm_addmore();" onclick="$(\'sortby\').onclick=\'\'">'+FM.lang.SEARCHMORE+'</a></td><td></td><td></td></tr></table></td></tr></table>';

	$('scroll_to_fort_list').innerHTML = fm_forts_div;
	FM.fm_add_popup($('sortby'), escape(fm_sortby_popup));
	if (fm_searchmore != true) {
	  $('searchmore').style.display="inline";
	}
	FM.fm_add_popup($('fort_list_closer'), escape(FM.lang.CLOSE));
  }

  function fm_check(fm_searchmore){
	if (fm_searchmore == "only") {
	  fm_forts_div = '<table id="new_fort_table" cellspacing="0"><tr><td><table><tr id="searchmore" style="display:inline"><td class="tdbottom" style="font-size: 8pt;" nowrap><a style="color:#143B50;" onmouseover="this.style.color=\'\';" onmouseout="this.style.color=\'#143B50\';" href="javascript:FM.fm_addmore();">'+FM.lang.SEARCHMORE+'</a></td></td><td></td><td><div style="cursor: pointer;" id="fort_list_closer" onclick="FM.fm_hide();"></div></td></tr><td></td><td></td></tr></table></td></tr></table>';
	  $('scroll_to_fort_list').innerHTML = fm_forts_div;
	}
	else{
	  if (fm_saveposition != pos.x+"_"+pos.y || fm_savecharspeed!=Character.speed){
		fm_saveposition = pos.x+"_"+pos.y;
		fm_savecharspeed=Character.speed;
		fm_make_array('false');
	  }
	}
	$('scroll_to_fort_list').style.display = "inline";
  }

  function fm_show(){
	if (fm_saveposition != pos.x+"_"+pos.y || fm_savecharspeed!=Character.speed){
	  fm_saveposition = pos.x+"_"+pos.y;
	  fm_savecharspeed=Character.speed;
	  if (fm_searchonly == true){
		fm_forts_array = new Array();
		fm_make_array('only');
		FM.fm_check('only');
	  }
	  else{
		fm_make_array('false');
	  }
	}
	$('scroll_to_fort_list').style.display = "inline";
  }

  function fm_hide(){
	$('scroll_to_fort_list').style.display = "none";
	if (fm_searchmore == true && fm_save_tab_lines == fm_tab_lines && fm_tab_lines != 0) {
	  $('searchmore').style.display="none";
	}
  }

  function fm_addmore(){
	fm_searchmore = true;
	fm_save_tab_lines = fm_tab_lines;
	$('searchmore').innerHTML = '<td style="font-size: 8pt;" nowrap>'+FM.lang.PLEASEWAIT+'</td><td></td><td></td>';

	for (var f in FM.fort){
	  if (fm_i > 0){
		for(fm_j=fm_i-1; fm_j>=0; fm_j--){
		  if (fm_forts_array[fm_j]["l_coord"] == FM.fort[f].x+"_"+FM.fort[f].y){
			fm_fort_exist = true;
			break;
		  }
		  else{
			fm_fort_exist = false;
		  }
		}
	  }
	  else{
		fm_fort_exist = false;
	  }
	  if (fm_fort_exist == false && FM.fort[f].duration < 120){ // Increasing this value will slow down the script and generate a lot of requests to The West servers. Moreover, it is useless. So please do not modify :)
		fm_forts_array[fm_i] = new Array(13);
		fm_forts_array[fm_i]={l_index:"9999", l_time:FM.fort[f].duration, l_fortname:"fortnearby", l_x:FM.fort[f].x, l_y:FM.fort[f].y, l_coord:FM.fort[f].x+"_"+FM.fort[f].y, l_owner:FM.lang.AFORTSNEARBY, l_lvl:FM.fort[f].size, l_type:"3", l_id:"-1", l_stars:"-1", l_hotelpopup:"-1", l_battle:"-1"};
		fm_get_ajax_data(fm_i, FM.fort[f].x, FM.fort[f].y);
		fm_i++;
	  }
	  else if(fm_fort_exist == false && FM.fort[f].duration >= 120 && fm_search_coord_battle_forts.indexOf("'"+FM.fort[f].x+"_"+FM.fort[f].y+"'") != -1){
		fm_forts_array[fm_i] = new Array(13);
		fm_forts_array[fm_i]={l_index:"9999", l_time:FM.fort[f].duration, l_fortname:"fortattack", l_x:FM.fort[f].x, l_y:FM.fort[f].y, l_coord:FM.fort[f].x+"_"+FM.fort[f].y, l_owner:FM.lang.AFORTSATTACKED, l_lvl:FM.fort[f].size, l_type:"3", l_id:"-1", l_stars:"-1", l_hotelpopup:"-1", l_battle:"-1"};
		fm_get_ajax_data(fm_i, FM.fort[f].x, FM.fort[f].y);
		fm_i++;
	  }
	}

	fm_prepare_div(fm_i);
  }

if(typeof window.FM == 'undefined'){
  try{
	window.FM = new Object();
	FM.lang = fm_lang;
	FM.fm_make_div = fm_make_div;
	FM.fm_addmore = fm_addmore;
	FM.fm_add_popup = fm_add_popup;
	FM.fm_setCookie = fm_setCookie;
	FM.fm_lvl_fort_src = fm_lvl_fort_src;
	FM.fm_check = fm_check;
	FM.fm_show = fm_show;
	FM.fm_hide = fm_hide;
	window.setTimeout(fm_init, 0);
  }catch(e){alert(e)}
}

})

ScriptUpdater.check(86724, fm_version());